#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int M=1e6+10;
struct{
    int di,vi,ai;
}car[N];
int test[M];
int t,n,m,l,v;
double cal(int v1,int v0,int a){
    return (v1*v1-v0*v0)*1.0/(2*a);
}
bool check(int x,int v){
    for(int i=1;i<=m;i++){
        if(car[x].di<=test[i]&&test[i]<car[x].di+cal(v,car[x].vi,car[x].ai))return true;
    }
    return false;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){

        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>car[i].di>>car[i].vi>>car[i].ai;
        }
        for(int i=1;i<=m;i++){
            cin>>test[i];
        }
        int ans1=0;
        sort(test+1,test+m+1);
        for(int i=1;i<=n;i++){
            if(car[i].ai==0){
                if(car[i].vi>v){
                    if(test[m]>car[i].di){
                            ans1++;
                    }
                }
            }
            else{
                if(car[i].vi>v||car[i].ai>0){
                    if(car[i].ai>0){
                        if(test[m]>car[i].di+cal(v,car[i].vi,car[i].ai))ans1++;
                    }
                    else{
                        if(check(i,v))ans1++;
                    }
                }
            }
        }
        cout<<ans1<<" "<<3;
    }
    return 0;
}
